#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=2e5+7;
int n, q, a, b, t;
int x[maxn];
ll pref[maxn];
map<int, int> diff;
int main() {
  cin>>n>>q;
  for(int i=1; i<=n; ++i) {
    cin>>x[i];
    pref[i] = x[i]+pref[i-1];
  }
  for(int i=0; i<q; ++i) {
    cin>>t>>a>>b;
    if(t==1) {
      diff[a]=b-x[a];  // diff
      x[a] = b;
    }
    else {
      int ans = pref[b]-pref[a-1];
      for(auto it=diff.lower_bound(a-1),
               ed=diff.upper_bound(b);
               it!=ed; ++it) {
        ans+=it->second;
      }
      cout<<ans<<endl;
    }
  }
  return 0;
}
